{-# LANGUAGE QuasiQuotes                #-}
{-# OPTIONS -Wall #-}

module Melody01 where


import Payasan.Base
import Payasan.Base.Names.GeneralMidiInstruments
import Payasan.Base.Names.Pitch

import Payasan.Models.Melody
import Payasan.Models.Melody.Parser -- temp


test01 = parsetest "M:4/2"
test02 = parsetest "4/2"

demo01 :: IO ()
demo01 = writeMF0 "out/vibes01.mid" $ renderMelodyPhrase vibesNote (mkTconfig vibraphone) $ 
    localize (set_bpm 180) $ mreplicate 4 $ melodyPhrase melody01


demo02 :: IO ()
demo02 = writeMF0 "out/accordion01.mid" $ renderMelodyPhrase accordionNote (mkTconfig accordion) $ 
    localize (set_bpm 180) $ mreplicate 4 $ melodyPhrase melody02


melody01 :: Melody
melody01 = makeMelody [ R 1, N c_4 1 ]


melody02 :: Melody
melody02 = [melody| M:4/4 \\ c G2 E2 C/2 |]

mkTconfig :: Int -> TrackData
mkTconfig pc = TrackData { channel_number    = 1
                         , program_change    = Just pc
                         , generic_text      = ""
                         , sequence_name     = ""
                         , instrument_name   = ""
                         }



vibesNote :: MelodyF
vibesNote = makeMelodyF $ \pch ->
    makeEventFw () 2.0 (NoteValue { note_pitch    = pitchToMidi pch
                                  , note_velo_on  = 65
                                  , note_velo_off = 65
                                  })


accordionNote :: MelodyF 
accordionNote = makeMelodyF $ \pch ->
    makeEvent () (NoteValue { note_pitch    = pitchToMidi pch
                            , note_velo_on  = 65
                            , note_velo_off = 65
                            })



